package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author WenYong
 */
@Entity(name = "UnstructuredContentPage")
public class UnstructuredContentPageEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long unstructuredContentPageId;
    private int templateNo;
    private String lang;
    private String pageName;
    @ManyToOne
    private UnstructuredContentEntity unstructuredContent;
    @OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, mappedBy = "unstructuredContentPage")
    private List<UnstructuredContentPanelEntity> unstructuredContentPanel = new ArrayList<UnstructuredContentPanelEntity>();

    public UnstructuredContentPageEntity() {
    }

    public UnstructuredContentPageEntity(int templateNo, String lang, String pageName, List<UnstructuredContentPanelEntity> unstructuredContentPanel) {
        this.templateNo = templateNo;
        this.lang = lang;
        this.pageName = pageName;
        this.unstructuredContentPanel = unstructuredContentPanel;
    }

    public Long getUnstructuredContentPageId() {
        return unstructuredContentPageId;
    }

    public void setUnstructuredContentPageId(Long unstructuredContentPageId) {
        this.unstructuredContentPageId = unstructuredContentPageId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (unstructuredContentPageId != null ? unstructuredContentPageId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the unstructuredContentPageId fields are not set
        if (!(object instanceof UnstructuredContentPageEntity)) {
            return false;
        }
        UnstructuredContentPageEntity other = (UnstructuredContentPageEntity) object;
        if ((this.unstructuredContentPageId == null && other.unstructuredContentPageId != null) || (this.unstructuredContentPageId != null && !this.unstructuredContentPageId.equals(other.unstructuredContentPageId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.UnstructuredContentPage[ id=" + unstructuredContentPageId + " ]";
    }

    public List<UnstructuredContentPanelEntity> getUnstructuredContentPanel() {
        return unstructuredContentPanel;
    }

    public void setUnstructuredContentPanel(List<UnstructuredContentPanelEntity> unstructuredContentPanel) {
        this.unstructuredContentPanel = unstructuredContentPanel;
    }

    public int getTemplateNo() {
        return templateNo;
    }

    public void setTemplateNo(int templateNo) {
        this.templateNo = templateNo;
    }

    public String getLang() {
        return lang;
    }

    public void setLang(String lang) {
        this.lang = lang;
    }

    public String getPageName() {
        return pageName;
    }

    public void setPageName(String pageName) {
        this.pageName = pageName;
    }

    /**
     * @return the unstructuredContentEntity
     */
    public UnstructuredContentEntity getUnstructuredContent() {
        return unstructuredContent;
    }

    /**
     * @param unstructuredContentEntity the unstructuredContentEntity to set
     */
    public void setUnstructuredContentEntity(UnstructuredContentEntity unstructuredContent) {
        this.unstructuredContent = unstructuredContent;
    }

}